<?php

use app\base\misc\datetimepicker\DateTimePicker;

use yii\helpers\Html;
use yii\helpers\Url;
use app\meta\widgets\MetaForm;
use app\tag\widgets\TagsInput;

use app\base\misc\adminlte\ActiveForm;
use app\tag\behaviors\Taggable;
use app\taxonomy\widgets\TaxonomySelect;
use app\taxonomy\behaviors\TaxonomyBehavior;
use app\attachment\widgets\SingleMediaWidget;
use app\base\enums\EntityStatusEnum;
use app\base\misc\editor\EditorWidget;
use app\comment\enums\CommentEnabledEnum;
use app\post\Module;

$form = ActiveForm::begin([
    'options' => [
        'enctype' => 'multipart/form-data',
        'class' => 'model-form'
    ]
]);
?>
<div class="col-md-9">
    <?= $form->field($model, 'title')->label(false) ?>
    <?= $form->boxField($model, 'short')->textarea()->header("文章摘要")->hint("摘要是可选的手工创建的内容总结，并可在您的主题中使用。") ?>
    <?= $form->field($model, 'content')->label(false)->widget(EditorWidget::className(), ["config" => ["class" => '\vova07\imperavi\Widget', 'settings' => ['lang' => 'zh_cn', 'minHeight' => 200, 'imageManagerJson' => Url::to(['/attachment/upload/images-get']), 'imageUpload' => Url::to(['/attachment/upload/create-imperavi']), 'fileUpload' => Url::to(['/attachment/upload/create-imperavi']), 'plugins' => ['clips', 'fullscreen', 'imagemanager', 'filemanager']]]]); ?>
    <?= $form->boxField($model, 'meta', ["collapsed" => true])->widget(MetaForm::className())->header("SEO"); ?>
</div>
<div class="col-md-3" style="padding-left:0px;">
    <div class="box box-solid">
        <div class="box-body">
            <div class="form-group">
                <label class="control-label"
                       style="float: left; padding-right: 5px;"> <?= $model->attributeLabels()['created_at'] ?>
                    :
                </label> <span> <?= $model->getCreatedDate(); ?>
				</span>
            </div>
            <div class="form-group">
                <label class="control-label"
                       style="float: left; padding-right: 5px;"> <?= $model->attributeLabels()['updated_at'] ?>
                    :
                </label> <span> <?= $model->getUpdatedDate() ?>
				</span>
            </div>
            <div class="form-group">
                <label class="control-label"
                       style="float: left; padding-right: 5px;"> <?= $model->attributeLabels()['revision'] ?>
                    :
                </label> <span> <?= $model->getRevision() ?>
				</span>
            </div>

            <?= Html::submitButton($model->isNewRecord ? '发布' : '更新', ['class' => 'btn bg-maroon btn-flat margin-bottom btn-block']) ?>

        </div>
    </div>

    <div class="box box-solid">
        <div class="box-body">
            <?= $form->field($model, 'slug'); ?>
            <?= $form->field($model, 'published_at')->widget(DateTimePicker::className()); ?>

            <?= $form->field($model, 'status')->dropDownList(EntityStatusEnum::listData()) ?>

            <?= $form->field($model, 'commentEnabled')->dropDownList(CommentEnabledEnum::listdata()) ?>

            <?php if (!$model->isNewRecord): ?>
                <?= $form->field($model, 'author_id')->dropDownList(Module::getUserList()) ?>
            <?php endif; ?>

        </div>
    </div>
    <?= $form->boxField($model, TaxonomyBehavior::$formName)->widget(TaxonomySelect::className())->header("选择分类"); ?>
    <?php
    echo $form->boxField($model, Taggable::$formName)
        ->widget(TagsInput::className())
        ->header("标签");
    ?>
    <?php
    echo $form->boxField($model, 'thumbnail')
        ->widget(SingleMediaWidget::className())
        ->header("特色图片");
    ?>
</div>

<?php ActiveForm::end(); ?>
